package com.th.admin.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author ThreePure
 * @date 2022/4/23 10:48
 * @description: 配置redis使用，每次请求都进行计数
 * @since 1.8
 */
//@Component
public class RedisUrlCountInterceptor implements HandlerInterceptor {
    //@Autowired
    //StringRedisTemplate redisTemplate;

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String uri = request.getRequestURI();

        //默认每次访问当前uri就会计数+1
        //redisTemplate.opsForValue().increment(uri);
        return true;
    }
}
